Repository navigation
feat(telemetry): derive failure_kind for run telemetry - #704
Conversation
automation_run_failed fires ~294k times per 90 days in PostHog with no error_kind/failure_reason, so failure analysis is impossible. Derive a closed-set failure_kind (timeout, verification_failed, dispatch_error, cancelled, execution_error) from the stored error_detail prefix in _base_properties, so every emission site (callback, watchdog, dispatcher) gains it automatically. The free-text error_detail itself is never sent to telemetry. Co-authored-by: openhands <openhands@all-hands.dev>
Preserve failure classification alongside SDK version caching and run-as telemetry. Co-authored-by: openhands <openhands@all-hands.dev>
|
Warning Your comment is too long (maximum is 65536 characters), so the coverage report was not added. See the job log for how to reduce it. |
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Fresh review of head 2a8cfe5. The change is correctly scoped to this repository: it normalizes error_detail on automation runs into a coarse, non-identifying failure_kind for PostHog telemetry, which is squarely in this service's ownership.
Verified against the workspace code:
- Prefix coverage matches the real writers.
Timed out: verification failed: …(watchdog.py:260) →verification_failed;Timed out: …(watchdog.py:325, 516) →timeout;Cancelled by user(router.py:1945) →cancelled;Failed to get execution context(dispatcher.py:1061) →dispatch_error; everything else →execution_error. The classifier checks the more specificverification_failedprefix before the genericTimed out:, so ordering is correct. - Override semantics preserved.
_capture_automation_eventbuilds base properties first and then applies callerproperties, so the explicit per-sitefailure_kindvalues in watchdog.py:279/:549 and dispatcher.py:812 still win, and they agree with what the classifier derives from the same rows. - No PII/secret leakage path.
_failure_kind_from_error_detailreturns only literal closed-set strings; the raw free-texterror_detail(which includes paths, stderr, callback errors) never enters properties. The new test plants a secret-like path and asserts it is absent, consistent with the repo guidance against persisting plaintext sensitive content in telemetry. - Reconciled-callback interaction is safe. When the completion callback flips a watchdog-timeout back to COMPLETED,
error_detailis cleared (router.py:1727), so no stalefailure_kindattaches to the completed event. - Tests.
uv run python -m pytest tests/test_telemetry.py -q→ 29 passed in the workspace. Dispatcher/router suites requiring the sessionpostgres_containerfixture could not run here (no Docker daemon in this environment) — that is a pre-existing environment limitation, not a PR issue; theunit-testsGitHub Actions check on this exact head is green and covers them, and theFailed to get execution contextprefix is additionally asserted intests/test_dispatcher.py:1685.
No material findings.
✅ APPROVED
Live production-path evidence (2026-11-13)Validated head
Current-head independent approvals already exist, so no additional review was requested. No code change was needed. Generated by an AI agent (OpenHands) on behalf of neubig. |
|
🚀 Released in 1.33.0. |
Why
PostHog (Agent Canvas project) shows
automation_run_failedfiring ~294k times per 90 days with noerror_kind/failure_reasonproperty at all, so run-failure analysis is impossible. The signal exists — the service stores free-texterror_detailon the run and three emission sites already set a partialfailure_kind— but nothing normalizes it, and the raw detail text (paths, URLs, script output) must never reach telemetry anyway.Discussed in Slack: https://allhandsai.slack.com/archives/C0BGK8NRYUX/p1793909181285009
Summary
telemetry.py: new_failure_kind_from_error_detail()maps the closed set of prefixes this service writes to a coarse, non-identifying category:Timed out: verification failed…→verification_failed,Timed out:…→timeout,Cancelled…→cancelled,Failed to get execution context→dispatch_error, anything else →execution_error, empty → no property._base_properties()attaches the derivedfailure_kindwhenever a run carries anerror_detail, so every emission site (router callback, watchdog verification/timeout, dispatcher) gains it automatically — including the sites that set nothing today. Explicit per-sitefailure_kindproperties still override via the existing property-merge order.error_detailitself is never sent; only the closed-set category.Tests
tests/test_telemetry.py, plus a base-properties test asserting the derived kind is present and the raw detail (including a planted secret path) does not leak into properties.uv run python -m pytest tests/test_telemetry.py -q→ 26 passed.Notes
automation_setup_blocked+entry_pointto the setup funnel; together they close the instrumentation gap identified in the P1 activation analysis (2,163 setup openers → 580 validated per 90 days, previously unattributable).This PR was created by an AI agent (OpenHands) on behalf of Graham Neubig.
Issue tracking
Part of OpenHands/automation#266 — Make terminal telemetry usable for unique-user automation funnels. This PR contributes to the shared tracker; merging it must not close the umbrella by itself.
This tracking update was made by an AI agent (OpenHands) on behalf of Graham Neubig.
Jev-Fast-Audit
⚡ Jev fast audit · estimates · 0.23s · commit 2a8cfe5
Strongest signal: No primary concern selected.
Evidence: No primary concern to locate.
Coverage: complete supplied coverage; 3/3 hunks, 2/2 files.
All estimates and evidence